package com.example.bms.storehouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.example.bms.storehouse.entity.StorehouseEntity;
import com.example.bms.storehouse.service.StorehouseService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;



/**
 * 
 *
 * @author Jiang
 * @email 337262603@qq.com
 * @date 2022-01-29 23:13:47
 */
@RestController
@RequestMapping("storehouse/storehouse")
@CrossOrigin
public class StorehouseController {
    @Autowired
    private StorehouseService storehouseService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("storehouse:storehouse:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = storehouseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{shid}")
    //@RequiresPermissions("storehouse:storehouse:info")
    public R info(@PathVariable("shid") Integer shid){
		StorehouseEntity storehouse = storehouseService.getById(shid);

        return R.ok().put("storehouse", storehouse);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("storehouse:storehouse:save")
    public R save(@RequestBody StorehouseEntity storehouse){
		storehouseService.save(storehouse);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("storehouse:storehouse:update")
    public R update(@RequestBody StorehouseEntity storehouse){
		storehouseService.updateById(storehouse);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("storehouse:storehouse:delete")
    public R delete(@RequestBody Integer[] shids){
		storehouseService.removeByIds(Arrays.asList(shids));

        return R.ok();
    }

}
